package com.demo.servlet.demo1209;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/demo1209/demo01.do")
public class Demo01Servlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //sendRedirect 方法中的字符串 是交给前端浏览器解析，所以/斜杠和前端一个规则
        //1.跳转服务器内相关资源
//        response.sendRedirect("./download.html");
        //http://localhost:8083/
//        response.sendRedirect("/demo1208/demo1209/download.html");
//        System.out.println("进入了 Demo01Servlet");
        //2.跳转到站外
        response.sendRedirect("https://www.baidu.com");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
